<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var obj = {
            name:"张三",
            myhobby:{
                a:"篮球",
                b:"足球"
            }
        };
        function fn(arg){
            var res=Array.isArray(arg) ? []:{};
            for(var key in arg){
                if(typeof arg[key]==="object"){
                    res[key]=fn(arg[key])
                }else{
                    res[key]=arg[key];
                }
            }return res;
        }
        var newarg=fn(obj);
        console.log(newarg);
    </script>
</body>
</html>